import { ActionContext } from 'vuex';
import { message } from 'ant-design-vue';
import { ResponseHandle } from '@/global/util/preUtils';
import { updateUserinfo, updatePassword } from '@/views/personal/api';

interface State {
  [key: string]: any;
}

const getInitData = (): State => {
  return {};
};
const state: State = getInitData();
const getters = {};
const actions = {
  async updateUserinfo(context: ActionContext<State, any>, params: any) {
    const res: any = await updateUserinfo(params);
    ResponseHandle(res, () => {
      message.success('修改成功');
      context.dispatch('root/getUserInfo', {}, { root: true });
    });
    return res;
  },
  async updatePassword(context: ActionContext<State, any>, params: any) {
    const res: any = await updatePassword(params);
    return res;
  },
};
const mutations = {};
export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
};
